home *** CD-ROM | disk | FTP | other *** search
- package com.extensibility.xml;
-
- import com.extensibility.util.Debug;
- import java.io.BufferedReader;
- import java.io.EOFException;
- import java.io.IOException;
- import java.io.Reader;
- import java.io.StringReader;
-
- final class ReaderContext implements Cloneable, ParserException.Context {
- public static final int UNKNOWN = 0;
- public static final int TYPE_MAIN_DOCUMENT = 1;
- public static final int TYPE_INTERNAL_GE = 2;
- public static final int TYPE_EXTERNAL_GE = 3;
- public static final int TYPE_INTERNAL_PE = 4;
- public static final int TYPE_EXTERNAL_PE = 5;
- public static final int TYPE_PADDING = 6;
- public static final int TYPE_MAX = 6;
- Reader readThis;
- Reader reader;
- int type;
- String name;
- String value;
- URI uri;
- int lineNo;
- int charNo;
- int unreadChar;
-
- public ReaderContext(int var1, URI var2) throws IOException {
- this(var2.createReader(), var1, "", "", var2);
- Debug.assert(var1 == 1, "Constructor should only be used for main document. From then on, a URI should be given.");
- this.readThis = new BufferedReader(this.reader);
- }
-
- public ReaderContext(URI var1, int var2, String var3, URI var4) throws IOException {
- this(var1.createReader(), var2, var3, "", var4);
- Debug.assert(var2 == 1 || var2 == 3 || var2 == 5 || var2 == 6, "Constructor should only be used for external references.");
- this.checkType();
- this.readThis = new BufferedReader(this.reader);
- }
-
- public ReaderContext(String var1, int var2, String var3, String var4, URI var5) {
- this((Reader)(new StringReader(var1)), var2, var3, var4, var5);
- this.checkType();
- }
-
- private ReaderContext(Reader var1, int var2, String var3, String var4, URI var5) {
- this.lineNo = 1;
- this.charNo = 1;
- this.reader = var1;
- this.readThis = this.reader;
- this.type = var2;
- this.name = var3;
- this.value = var4;
- this.uri = var5;
- this.checkType();
- }
-
- public Object clone() {
- Object var1;
- try {
- var1 = super.clone();
- } catch (Exception var4) {
- Object var3 = null;
- return var3;
- }
-
- this.reader = null;
- return var1;
- }
-
- public URI getURI() {
- return this.uri;
- }
-
- public String getValue() {
- return this.value;
- }
-
- public int getType() {
- this.checkType();
- return this.type;
- }
-
- public String getName() {
- return this.name;
- }
-
- protected void checkType() {
- Debug.assert(this.type >= 1 && this.type <= 6, String.valueOf("Invalid type: ").concat(String.valueOf(this.type)));
- }
-
- public void close() {
- try {
- if (this.reader != null) {
- this.reader.close();
- }
- } catch (IOException var2) {
- }
-
- }
-
- public int unread(char var1) throws EOFException {
- if (this.unreadChar != 0) {
- throw new EOFException();
- } else {
- this.unreadChar = var1;
- return 0;
- }
- }
-
- public int read() throws IOException {
- int var1;
- if (this.unreadChar != 0) {
- var1 = this.unreadChar;
- this.unreadChar = 0;
- } else {
- var1 = this.readThis.read();
- if (var1 == 10) {
- ++this.lineNo;
- this.charNo = 0;
- } else {
- ++this.charNo;
- }
- }
-
- return var1;
- }
-
- public int getLine() {
- return this.lineNo;
- }
-
- public int getColumn() {
- return this.charNo;
- }
-
- public boolean isInternal() {
- this.checkType();
- return this.type == 2 || this.type == 4;
- }
-
- public void mark(int var1) throws IOException {
- this.readThis.mark(var1);
- }
-
- public void reset() throws IOException {
- this.readThis.reset();
- }
- }
-